#pragma once
#include "CFrameVectorBuffer.h"
#include "IPALRenderWalkTarget.h"
#include "CXcpList.h"
#include "CRasterizerEdgeStore.h"

class CCompositeVectorBuffer :
	public CFrameVectorBuffer,
	public IPALRenderWalkTarget
{
public: 
	static HRESULT OWCreate(XUINT32, CCompositeVectorBuffer * *);
	static HRESULT NWCreateForLocalMemorySurfaces(enum PixelFormat pixelFormat, XUINT32 backgroundColor, CCompositeVectorBuffer * * ppVectorBuffer);
	static HRESULT NWCreateForRenderTargetSurfaces(struct ICoreRenderTarget *, XUINT32, XUINT32, CCompositeVectorBuffer * * ppVectorBuffer);
	virtual ~CCompositeVectorBuffer();
	virtual HRESULT RasterizeFrame(enum XSURFTYPE surfaceType, struct ICoreServices * pICoreServices, XBOOL fFullRedraw, XBOOL fEnableDirtyRegionsDisplay, struct XRECT_WH * prcDirtyRect);
	virtual HRESULT ResetWithoutRasterize();
	virtual XBOOL GetIsCached() const;
	virtual XBOOL IsClearTypeEnabled() const;
	virtual XINT32 GetRenderedOffsetX() const;
	virtual XINT32 GetRenderedOffsetY() const;
	virtual XINT32 GetRenderedWidth() const;
	virtual XINT32 GetRenderedHeight() const;
	void UpdateRenderedSize();
	void UpdateRenderedOffsets(XINT32, XINT32);
	virtual XBOOL IsEmpty() const;
	virtual XINT32 GetMaximumWidth() const;
	virtual XINT32 GetMaximumHeight() const;
	virtual XBOOL HasDimensions() const;
	virtual XINT32 GetWidth() const;
	virtual XINT32 GetHeight() const;
	void GetSubpixelRenderedBounds(struct XRECTF_WH *);
	void ComputeSize();
protected: 
	virtual void Reset();
	virtual HRESULT AddEdgeStoreInternal(CRasterizerEdgeStore * pRasterizerEdgeStore, XBOOL fEdgeStoreLeaving);
private: 
	static HRESULT CreateCore(struct ICoreRenderTarget * pNWRenderTarget, XBOOL forceLocalMemorySurfaces, XBOOL enableClearType, enum PixelFormat pixelFormat, XUINT32 backgroundColor, CCompositeVectorBuffer * * ppVectorBuffer);

private: 
	CCompositeVectorBuffer(struct ICoreRenderTarget * pNWRenderTarget, XBOOL forceLocalMemorySurfaces, XBOOL enableClearType, enum PixelFormat pixelFormat, struct ArgbPixel backgroundColor);
	CXcpList<CRasterizerEdgeStore> m_oEdgeStoreList;
	XINT32 m_nVectorBufferOffsetX;
	XINT32 m_nVectorBufferOffsetY;
	XINT32 m_nVectorBufferWidth;
	XINT32 m_nVectorBufferHeight;
	XBOOL m_fFlushed;
	XBOOL m_enableClearType;
	XFLOAT m_rSubpixelOffsetX;
	XFLOAT m_rSubpixelOffsetY;
	XFLOAT m_rSubpixelWidth;
	XFLOAT m_rSubpixelHeight;
};